<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@page import="com.householdregister.HouseHoldRegisterVO"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List list = (List)request.getAttribute("list");
%>
<html> 
	<head> 
	<title>农村道路交通安全户籍化管理台账打印页</title> 
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
	<!--media=print 这个属性可以在打印时有效--> 
	<style media=print> 
		.Noprint{display:none;}<!--用本样式在打印时隐藏非打印项目--> 
		.PageNext{page-break-after: always;}<!--控制分页-->
	</style>

	<style>
		.style_tab_head 
		{ 
		font-family: "仿宋_GB2312"; 
		font-size: 22pt; 
		}
		.forcePage
		{
		page-break-after : always;
		}
		.style_td 
		{ 
		border-bottom: 1 solid #000000; 
		border-left: 1 solid #000000; 
		border-right: 0 solid #ffffff; 
		border-top: 0 solid #ffffff;
		text-align: center;
		height : 33px;
		}
		.style_tab 
		{ 
		border-color: #000000 #000000 #000000 #000000; 
		border-style: solid; 
		border-top-width: 2px; 
		border-right-width: 2px; 
		border-bottom-width: 1px; 
		border-left-width: 1px; 
		}
		.NOPRINT { 
		font-family: "宋体"; 
		font-size: 9pt; 
		}
	</style>
	</head>
	
	<body>
		<center class="Noprint"> 
			<p> 
				<input type=button value=返回 onclick="window.history.back()"> 
			</p> 
		</center>
		<%
			int sum = 0;
			int pageCount = 0;
			if (null != list) {
				sum = list.size();
				if (sum % 13 == 0) {
					pageCount = sum / 13;
				} else {
					pageCount = (sum / 13)+1;
				}
			}
			for (int i = 0; null != list && i < pageCount; i++) {
				if (i != 0) {
		%>
		<div class="forcePage">&nbsp;</div>
		<%
				}
		%>
		<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0">
			<tr>
				<td colspan="3" width="100%">&nbsp;</td> 
			</tr>
			<tr>
				<td colspan="3" width="100%">&nbsp;</td> 
			</tr>
			<tr>
				<td colspan="3" width="100%">&nbsp;</td> 
			</tr>
			<tr>
				<td colspan="3" align="center" class="style_tab_head">农村道路交通安全户籍化管理台账</td> 
			</tr> 
			<tr>
				<%
					//默认第一个的中队名称
					HouseHoldRegisterVO vo0 = (HouseHoldRegisterVO) list.get(0);
					String squadron = "&nbsp;";
					if (vo0.getSquadron() != null && !"".equals(vo0.getSquadron())) {
						squadron = vo0.getSquadron();
					}
					//默认第一个的屯名称
					String tun = "&nbsp;";
					if (vo0.getVillage() != null && !"".equals(vo0.getVillage())) {
						tun = vo0.getVillage();
					}
					//默认第一个的村名称
					String cun = "&nbsp;";
					if (vo0.getBigvillage() != null && !"".equals(vo0.getBigvillage())) {
						cun = vo0.getBigvillage();
					}
				%>
				<td width="35%">&nbsp;</td> 
				<td width="35%">&nbsp;</td> 
				<td width="30%"><%=squadron%></td>
			</tr>
			<tr> 
				<td colspan="3">
					<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" class="style_tab"> 
						<tr> 
							<td width="5%" class="style_td" rowspan="2">序  号</td>
							<td width="11%" class="style_td" rowspan="2">姓名</td>
							<td width="15%" class="style_td" rowspan="2">身份证号码</td>
							<td width="12%" class="style_td" rowspan="2">联系电话</td>
							<td width="12%" class="style_td">A：有机动车</td>
							<td width="10%" class="style_td" rowspan="2">车型</td>
							<td width="4%" class="style_td" rowspan="2">落户</td>
							<td width="12%" class="style_td" rowspan="2">车牌号码</td>
							<td width="11%" class="style_td" rowspan="2">购车时间</td>
							<td width="7%" class="style_td" rowspan="2">准驾车型</td>
						</tr> 
						<tr> 
							<td width="10%" class="style_td">B：无机动车</td>
						</tr>
						
						<%
							for (int j=i*13; j<(i+1)*13 && j<list.size(); j++) {
								HouseHoldRegisterVO vo = (HouseHoldRegisterVO) list.get(j);
								String name = "&nbsp;";
								if ( vo.getName()!=null && !"".equals(vo.getName())) {
									name = vo.getName();
								}
								String idcardnumber = "&nbsp;";
								if ( vo.getIdcardnumber()!=null && !"".equals(vo.getIdcardnumber())) {
									idcardnumber = vo.getIdcardnumber();
								}
								String phonenumber = "&nbsp;";
								if ( vo.getPhonenumber()!=null && !"".equals(vo.getPhonenumber())) {
									phonenumber = vo.getPhonenumber();
								}
								String car = "&nbsp;";
								if ( vo.getCar()!=null && !"".equals(vo.getCar())) {
									car = vo.getCar();
								}
								String platetype = "&nbsp;";
								if ( vo.getPlatetype()!=null && !"".equals(vo.getPlatetype())) {
									platetype = vo.getPlatetype();
								}
								String settle = "&nbsp;";
								if ( vo.getSettle()!=null && !"".equals(vo.getSettle())) {
									settle = vo.getSettle();
									if (settle.contains("1")) {
										settle = "是";
									} else {
										settle = "否";
									}
								}
								String platenumber = "&nbsp;";
								if ( vo.getPlatenumber()!=null && !"".equals(vo.getPlatenumber())) {
									platenumber = vo.getPlatenumber();
								}
								String buytime = "&nbsp;";
								if ( vo.getBuytime()!=null && !"".equals(vo.getBuytime())) {
									buytime = vo.getBuytime();
								}
								String drivingtype = "&nbsp;";
								if ( vo.getDrivingtype()!=null && !"".equals(vo.getDrivingtype())) {
									drivingtype = vo.getDrivingtype();
								}
						%>
						<tr> 
							<td width="7%" class="style_td"><%=j+1%></td>
							<td width="11%" class="style_td"><%=name%></td>
							<td width="15%" class="style_td"><%=idcardnumber%></td>
							<td width="10%" class="style_td"><%=phonenumber%></td>
							<td width="12%" class="style_td"><%=car%></td>
							<td width="10%" class="style_td"><%=platetype%></td>
							<td width="4%" class="style_td"><%=settle%></td>
							<td width="12%" class="style_td"><%=platenumber%></td>
							<td width="11%" class="style_td"><%=buytime%></td>
							<td width="7%" class="style_td"><%=drivingtype%></td>
						</tr>
						<%
							}
						%>
					</table>
				</td> 
			</tr>
			<tr style="height:10px;">
				<td width="50%">&nbsp;</td>
				<td width="20%">&nbsp;&nbsp;</td> 
				<td width="30%">&nbsp;&nbsp;</td>
			</tr>
			<tr>
				<td width="30%">&nbsp;</td> 
				<!-- <td width="20%">第&nbsp;&nbsp;<%=i+1%>&nbsp;页</td>  -->
				<td width="50%"><%=cun%>村&nbsp;<%=tun%>屯</td>
			</tr>
		</table>
		<%
			}
		%>
	</body> 
</html>
<script language="javascript">
	var hkey_root="HKEY_CURRENT_USER" ; 
	var hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; 
	var hkey_key;
	function doPrint() {    
		//直接调用WebBrowser的打印，要打印预览的话是ExecWB(7,1) 直接打印ExecWB(6,6)
     	document.all.WebBrowser.ExecWB(6,6); 
	} 
	//设置纸张方向 
	function setupLandscape() { 
		try{ 
			var wsShell= new ActiveXObject("WScript.Shell"); 
			//打印页面的Menubar必须可见，此操作类似按键盘上的Alt+F+U也就是 调出页面设置对话框 
			wsShell.sendKeys('%fu'); 
			//此操作类似按键盘上的Alt+A也就是 设置横向打印 
			wsShell.sendKeys('%a');
			//此操作类似按键盘上的Alt+O也就是 设置竖向打印 
			//wsShell.sendKeys('%o'); 
			//此操作类似按键盘上的回车 页面设置对话框的默认焦点在 确定上 所以直接确定 
			wsShell.sendKeys('{ENTER}'); 
		} 
		catch(e){} 
	} 
	//设置默认的页眉页脚 
	function setupPage() { 
		try{ 
		var RegWsh = new ActiveXObject("WScript.Shell"); 
			hkey_key="header" 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") 
			hkey_key="footer" 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&b") //去掉了&u 因为我不想显示当前打印页的网址 
			hkey_key="margin_bottom"; 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.39"); //0.39相当于把页面设置里面的边距设置为10 
			hkey_key="margin_left"; 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.39"); 
			hkey_key="margin_right"; 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.39"); 
			hkey_key="margin_top"; 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.39"); 
		} 
		catch(e){} 
	} 
	setTimeout("setupLandscape()",1000); 
	setTimeout("setupPage()",2000); 
	setTimeout("doPrint()",3000); 
</script>